package com.qire.manhua.controller;

import android.view.View;

import com.qire.antsrouter.AntsRouter;
import com.qire.antsrouter.card.FloorCard;
import com.qire.common.basic.ObjectUtil;
import com.qire.common.constant.Navigation;
import com.qire.common.support.base.EventController;
import com.qire.common.widget.adapter.auto.AutoVariable;
import com.qire.manhua.activity.ComicRankListOfVipActivity;
import com.qire.manhua.databinding.LayoutComicRankListOfVipItemBinding;
import com.qire.manhua.model.viewModel.impl.ComicRankListOfVipViewModel.ComicRankListOfVipItemViewModel;
import com.qire.other.recorder.ComicActionRecorder;

import androidx.annotation.NonNull;

public class ComicRankListOfVipController extends EventController<ComicRankListOfVipActivity> implements AutoVariable<LayoutComicRankListOfVipItemBinding> {

    public ComicRankListOfVipController(@NonNull ComicRankListOfVipActivity owner) {
        super(owner);
    }

    @Override
    protected void bindView() {
        owner.viewDataBinder().setComicRankListOfVipController(this);
    }

    @Override
    public void bindVariable(LayoutComicRankListOfVipItemBinding viewBind) {
        viewBind.setComicRankListOfVipController(this);
    }

    /*************************************************************************************************************************/

    public void backBtnOnClick(View view) {
        owner.onBackPressed();
    }

    public void searchBtnOnclick(View view) {
        AntsRouter.ROUTER.buildCard(Navigation.Page.ComicSearchPage).navigation();

        // 行为数据统计
        ComicActionRecorder.build(ComicActionRecorder.count_search_click)
                .setSource("VIP人气榜")
                .doRecorde(view.getContext());
    }

    public void rankItemOnClick(View view) {
        ComicRankListOfVipItemViewModel itemViewModel = ObjectUtil.as(view.getTag(), ComicRankListOfVipItemViewModel.class);
        if(ObjectUtil.nonNull(itemViewModel)) {
            AntsRouter.ROUTER.<FloorCard>buildCard(Navigation.Page.ComicDetailPage)
                    .withData("comicBookId", itemViewModel.comicId)
                    .navigation();
        }
    }

}
